package cn.kgc.common.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * Created by teacher ZHANG on 2022/11/14
 */
@Data
//tableName-实体类对应的表名，resultMap-对应的结果转换配置
@TableName(value = "article", resultMap = "articleMap")
//可序列化，可以把对象转换为一个一个的字节串
public class Article implements Serializable {
    //自增主键
    @TableId(type = IdType.AUTO)
    private Integer articleId;
    private String title;
    private String summary;
    private String content;
    private String image;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date createDate;
    //此字段数据库中不存在
    @TableField(exist = false)
    private Category category;
    //评论量
    @TableField(exist = false)
    private Integer commentNum;
    //访问用户的数量
    @TableField(exist = false)
    private Integer visitorNum;
}
